`
https://leetcode.cn/problems/valid-parentheses/
`

/**
 * @param {string} s
 * @return {boolean}
 */
var isValid = function (s) {
  const map = {
    ')': '(',
    ']': '[',
    '}': '{'
  }

  const stk = []

  for (const c of s) {
    if (c === ')' || c === ']' || c === '}') {
      if (stk[stk.length - 1] !== map[c] || stk.length === 0) return false
      stk.pop()
    } else {
      stk.push(c)
    }
  }

  return stk.length > 0 ? false : true
};